import { computed, ref } from 'vue'
import zhCN from 'tdesign-mobile-vue/es/locale/zh_CN'

// 当前语言
const locale = ref('zh-CN')

// 组件库语言配置
const getComponentsLocale = computed(() => {
  switch (locale.value) {
    case 'zh-CN':
    default:
      return zhCN
  }
})

// 设置语言
const setLocale = (lang: string) => {
  locale.value = lang
}

export const useLocale = () => {
  return {
    locale: computed(() => locale.value),
    getComponentsLocale,
    setLocale
  }
}